<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/Mock.js/1.0.0/mock-min.js"></script>
</head>

<body>
    <h1>testMock</h1>

    <script>
        const Random = Mock.Random
        const a = Mock.mock({
            'num1|50-100.1-3': 1,
            'img-1': '@image("200x100", "#000", "#fff", "png", "Mock.js")',
            avatar: "@image('200×100','#000','fff','png','avatar')"
        })
        const b = Random.dataImage('200×200', 'red', 'avatar');
        console.log(a)
        console.log(b)



        //自行扩展，各种商店名称 
        Mock.Random.extend({
            cstore() {
                return this.pick([
                    '宠物店',
                    '美容店',
                    '小吃店',
                    '数码店',
                    '快餐店'
                ]);
            }
        });
        //扩展调用 
        console.log(Mock.mock('@cstore'));


        const axios = require('axios');
        //使用 get 请求获取数据 
        axios.get('https://cdn.liyanhui.com/data.json')
            .then(res => {
                console.log(res.data);
            })
            .catch(err => {
                console.log('错误：' + err);
            });
    </script>
</body>

</html>